﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WodLib.Controls
{
    public partial class StateOfBeingEditorForm : Form
    {
        private WodLib.StateOfBeing health;

        public WodLib.StateOfBeing NewHealth { get; set; }

        private void RefreshDisplay()
        {
            labelBoxesDisplay.Text = health.ToString();
            labelDicePenalty.Text = health.DiceRollPenalty.ToString();
            labelStatusInfo.Text = "";
            if (health.DoIncapacitationRoll)
            {
                labelStatusInfo.Text += "DoIncapTest, ";
            }
            if (health.IsAlive)
            {
                labelStatusInfo.Text += "Alive, ";
            }
            else
            {
                labelStatusInfo.Text += "Dead, ";
            }
            if (health.IsDying)
            {
                labelStatusInfo.Text += "Dying";
            }
        }

        private void DealDamage(WodLib.DamageType dmg)
        {
            try
            {
                int count = Convert.ToInt32(textBoxDamageCount.Text);
                health.DealDamage(dmg, count);
            }
            catch (System.FormatException)
            {

            }
        }

        public StateOfBeingEditorForm(WodLib.StateOfBeing health)
        {
            InitializeComponent();
            this.NewHealth = health;
            this.health = (WodLib.StateOfBeing)health.Clone();
        }

        private void StateOfBeingEditorForm_Load(object sender, EventArgs e)
        {
            RefreshDisplay();
        }

        private void buttonBashing_Click(object sender, EventArgs e)
        {
            DealDamage(DamageType.Bashing);
            RefreshDisplay();
        }

        private void buttonLethal_Click(object sender, EventArgs e)
        {
            DealDamage(DamageType.Lethal);
            RefreshDisplay();
        }

        private void buttonAggravated_Click(object sender, EventArgs e)
        {
            DealDamage(DamageType.Aggravated);
            RefreshDisplay();
        }

        private void buttonHeal_Click(object sender, EventArgs e)
        {
            health.HealDamage();
            RefreshDisplay();
        }

        private void buttonDowngrade_Click(object sender, EventArgs e)
        {
            health.DowngradeWound();
            RefreshDisplay();
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            NewHealth = health;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
